﻿using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;

namespace Dilon.Core
{
    /// <summary>
    /// 角色表
    /// </summary>
    [SugarTable("sys_role", TableDescription = "角色表")]
    public class SysRole : DEntityBase
    {
        /// <summary>
        /// 名称
        /// </summary>
        [SugarColumn(ColumnDescription="名称")]
        public string Name { get; set; }

        /// <summary>
        /// 编码
        /// </summary>
        [SugarColumn(ColumnDescription="编码")]
        public string Code { get; set; }

        /// <summary>
        /// 排序
        /// </summary>
        [SugarColumn(ColumnDescription="排序")]
        public int Sort { get; set; }

        /// <summary>
        /// 数据范围类型（字典 1全部数据 2本部门及以下数据 3本部门数据 4仅本人数据 5自定义数据）
        /// </summary>
        [SugarColumn(ColumnDescription="数据范围类型")]
        public int DataScopeType { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        [SugarColumn(ColumnDescription="备注")]
        public string Remark { get; set; }

        /// <summary>
        /// 状态（字典 0正常 1停用 2删除）
        /// </summary>
        [SugarColumn(ColumnDescription="状态")]
        public CommonStatus Status { get; set; } = CommonStatus.ENABLE;

        /// <summary>
        /// 多对多（用户）
        /// </summary>
        [SqlSugar.SugarColumn(IsIgnore = true)]
        public ICollection<SysUser> SysUsers { get; set; }

        /// <summary>
        /// 多对多中间表（用户角色）
        /// </summary>
        [SqlSugar.SugarColumn(IsIgnore = true)]
        public List<SysUserRole> SysUserRoles { get; set; }

        /// <summary>
        /// 多对多（机构）
        /// </summary>
        [SqlSugar.SugarColumn(IsIgnore = true)]
        public ICollection<SysOrg> SysOrgs { get; set; }

        /// <summary>
        /// 多对多中间表（角色-机构 数据范围）
        /// </summary>
        [SqlSugar.SugarColumn(IsIgnore = true)]
        public List<SysRoleDataScope> SysRoleDataScopes { get; set; }

        /// <summary>
        /// 多对多（菜单）
        /// </summary>
        [SqlSugar.SugarColumn(IsIgnore = true)]
        public ICollection<SysMenu> SysMenus { get; set; }

        /// <summary>
        /// 多对多中间表（角色-菜单）
        /// </summary>
        [SqlSugar.SugarColumn(IsIgnore = true)]
        public List<SysRoleMenu> SysRoleMenus { get; set; }

    }
}
